package models

import (
	"github.com/astaxie/beego/orm"
	"strconv"
)

type AIVoiceLibrary struct {
	Id         int64
	Process_id int64
	Topic      string
	Voice_path string
	Voice_type string
}

func (a *AIVoiceLibrary) TableName() string {
	return TableName("voice_library")
}

func VoiceLibraryAdd(p *AIVoiceLibrary) (int64, error) {
	return orm.NewOrm().Insert(p)
}

//获取列表
func ParamGetListByTape(tplid int64) ([][]*AIVoiceLibrary) {
	lists := make([][]*AIVoiceLibrary, 0)
	var err error
	for i:=0; i<6; i++ {//获取6个变量类型
		list := make([]*AIVoiceLibrary, 0)
		query := orm.NewOrm().QueryTable(TableName("voice_library"))
		_, err = query.OrderBy("id").Filter("voice_type",strconv.Itoa(i)).Filter("process_id",strconv.FormatInt(tplid,10)).All(&list)
		lists = append(lists, list)
	}

	if err != nil {
		ErrorLog(err)
	}
	return lists
}